package com.hyf.popupdemo.support;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.RelativeLayout;

/**
 * Created by Administrator on 2018/4/16.
 */

public class PopwindowMenuRelativeLayout extends RelativeLayout implements PopWindowMenuHelper.OnClickViewPosition {
    private int[] clickPositions = new int[2];

    public PopwindowMenuRelativeLayout(Context context) {
        super(context);
    }

    public PopwindowMenuRelativeLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public PopwindowMenuRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            clickPositions[0] = (int) event.getRawX();
            clickPositions[1] = (int) event.getRawY();
        }
        return super.onTouchEvent(event);
    }

    @Override
    public int[] getClickPosition() {
        return clickPositions;
    }
}
